$(document).ready(function(){
	$('#grid_stu').datagrid({ 
		url:"findStuInfoList.html",
		fit:true,
		fitColumns:true, 
		singleSelect:true,
		pageSize:10,
	    pageNumber:1,
		columns:[[
			{field:'stuName',title:'学生姓名',width:60,resizable:false,align:'center'}, 
			{field:'school',title:'学校名称',width:60,resizable:false,align:'center'}, 
			{field:'grade',title:'年级',width:60,resizable:false,align:'center'}, 
			{field:'address',title:'地址',width:120,resizable:false,align:'center'},
			{field:'phone',title:'电话',width:120,resizable:false,align:'center'},
			{field:'option',title:'操作',width:60,resizable:false,align:'center',
				formatter:function(value,rowData){
		        return "<a  style='font-size:normal;color:#cc0000;cursor:pointer;' onClick=doDelete('"+rowData.stuId+"')>【删除】</a>&nbsp;"+
		        "<a  style='font-size:normal;color:#cc0000;cursor:pointer;' href='initStuInfoUpdate.html?stuId="+rowData.stuId+"'>【修改】</a>&nbsp;"+
		        "<a  style='font-size:normal;color:#cc0000;cursor:pointer;' onClick=uploadInfo('"+rowData.stuName+"')>【上传详情】</a>&nbsp;";
					}
			}]],
		toolbar:'#toolbar',
		pagination:true,
	}); 
});
/**
 * 删除问答信息
 */
function doDelete(id){
        $.messager.confirm('提示信息', "您确认删除吗？", function(rf) {
            if(rf){
            	$.ajax({
            		   type: "POST",
            		   url: "deleteStuInfo.html",
            		   data: {stuId:id},
            		   success: function(r){
            			   $.messager.alert('提示信息',r.msg,"", function () {
            				   window.location.reload();
            			   });
            		   }
            		});
            }
        });            
}


/**
 * 查询功能
 */
function doSearch(){
	//更新查询条件
	$('#grid_stu').datagrid({
			pageNumber:1,
			queryParams:{userName:$("#userName").val()}
	});
}

/** 查询输入框回车事件 */
function onEnter(){
    if(event.keyCode == 13){
    	doSearch();
	}
}
function uploadInfo(name){
	/** 上传详情*/
	$('#uploadDetialWin').window({
	    title: '上传详情',
	    href:'viewStuDetailView.html?stuName='+name,
	    width: 820,
	    height: 450,
	    top: ($(window).height() - 450) * 0.5,
	    left: ($(window).width() - 820) * 0.5,
	    shadow: true,
	    modal: true,
	    closed: true,
	    minimizable: false,
	    maximizable: false,
	    collapsible: false
	});
	$('#uploadDetialWin').window('open');
}




